package com.tedu.weibo.config;

import com.tedu.weibo.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 注册拦截使用的配置类
 * */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册拦截器,在发表微博和评论时，需要登录，因此需要拦截
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/v1/weibo/insert","/v1/comment/insert");
    }
}
